<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h1>ajax入门案例</h1>
		<script src="../js/axios.js"></script>
		<!-- AJax  局部刷新，异步访问 -->
		<script>
			//3.Axios优化   公共路径部分
			axios.defaults.baseURL="http://localhost:8080";		
			//1.promise是Axios封装
			let url1="/a/f";
			axios.get("/a/f")
				.then(function(promise){
					console.log(promise)//Object
					console.log(promise.data)
				})
				
				//2.带有参数的调用
				let url2="http://localhost:8080/a/axios/getByid?id=102";
				axios.get(url2)
						.then(function(promise){
							console.log(promise.data)
						})	
				//3.对象参数传递  http://localhost:8080/axios/getByid?id=102&name=tomcat
							let user3 = {age:100,name:"tomcat"}
										axios.get("/a/axios1/findUser1",{params: user3})
											 .then(function(promise){
												 console.log(promise.data)
											 })		
																 
				//4.RestFul结构实现数据传递  第一种:简单操作
							let rest1 = {sex: "女",name: "女神",age: 109}
							axios.get("/a/axios2/result2/"+rest1.ex+"/"+rest1.name+"/"+rest1.age)
								 .then(function(promise){
									 console.log(promise.data)
									 							 
								 })
								 
				//5.RestFul  http://localhost:8080/axios/getByid?id=102&name=tomcat
				let rest2 = {sex: "男",name: "tomcat",age: 99}
							axios.get(`/a/axios3/result3/${rest2.id}/${rest2.name}/${rest2.age}`)
			
					//模板字符串 保证代码格式
								let div = `<div>
												<p>天青色等烟雨</p>
												<p>而我在等你</p>
												<p>炊烟袅袅升起</p>
												<p>隔江千万里</p>
										   </div>`	
		</script>
	</body>
</html>
